#include "IMotion.h"

IMotion::IMotion(Vector2 position, real velocity, real minvelocity, real maxvelocity, real acceleration, real deceleration) : position(position), velocity(velocity), minvelocity(minvelocity), maxvelocity(maxvelocity), acceleration(acceleration), deceleration(deceleration)
{
}

Vector2 IMotion::getPosition()
{
    return position;
}

real IMotion::getVelocity()
{
    return velocity;
}

real IMotion::getMinVelocity()
{
    return minvelocity;
}

real IMotion::getMaxVelocity()
{
    return maxvelocity;
}

real IMotion::getAcceleration()
{
    return acceleration;
}

real IMotion::getDeceleration()
{
    return deceleration;
}

void IMotion::setPosition(Vector2 val)
{
    position = val;
}

real IMotion::setVelocity(real val)
{
    return velocity = val;
}

real IMotion::setMinVelocity(real val)
{
    return minvelocity = val;
}

real IMotion::setMaxVelocity(real val)
{
    return maxvelocity = val;
}

real IMotion::setAcceleration(real val)
{
    return acceleration = val;
}

real IMotion::setDeceleration(real val)
{
    return deceleration = val;
}

void IMotion::motion(real delta, real rad)
{
    position.x += (velocity * delta) * so_cos(rad);
    position.y += (velocity * delta) * so_sin(rad);
}

void IMotion::update(real delta)
{
    velocity += acceleration * delta;
    velocity = so_between(velocity, minvelocity, maxvelocity);
}
